package com.java2nb.novel.pay.controller;

import com.alibaba.fastjson.JSON;
import com.java2nb.novel.pay.dto.QueryPayOrderRequestDTO;
import com.java2nb.novel.pay.service.PayOrderQueryService;
import com.java2nb.novel.pay.vo.QueryPayOrderResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/pay")
@Api(tags = "支付订单接口")
@Slf4j
public class PayOrderQueryController {
    @Autowired
    private PayOrderQueryService payOrderQueryService;

    @PostMapping("/query")
    @ApiOperation("查询支付订单")
    public QueryPayOrderResponseVO queryPayOrder(
            @Validated @RequestBody QueryPayOrderRequestDTO requestDTO) {
        log.info("接收查询支付订单请求：{}", JSON.toJSONString(requestDTO));
        QueryPayOrderResponseVO response = payOrderQueryService.queryPayOrder(requestDTO);
        log.info("查询支付订单响应：{}", JSON.toJSONString(response));
        return response;
    }
}